<template>
  <div>
    <div class="breadcrumb_wrap">
      <span class="current">当前位置：</span>
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/personalcenter' }">个人中心</el-breadcrumb-item>
        <el-breadcrumb-item>作品中心</el-breadcrumb-item>
        <el-breadcrumb-item>我的发布</el-breadcrumb-item>
        <el-button
          style="position: absolute; right: 10px; top: 5px"
          type="primary"
          plain
          size="small"
          @click="toDoctorCertify"
        >医生认证</el-button>
      </el-breadcrumb>
    </div>

    <div class="page_card">
      <articleShow hasDel :articleList='articleList' @delete="handleArticleDel" />
    </div>

  </div>
</template>

<script>
// import articleShow from "@/components/articleShow.vue";
import articleShow from "@/components/pubList.vue";
// import articleShow from "@/components/draftsArticle.vue";
export default {
  name: 'pubs',
  components: {
    articleShow
  },
  watch: {
    $route: {
      handler() {
        this.tabsActive = this.$route.query.tab;
      },
      deep: true,
    },
  },
  data() {
    return {
      tabsActive: 'pub',
	  articleList:[]
    }
  },
  mounted() {
  	this.getPublishList();
  },
  methods: {
    handleArticleDel(artId) {
      this.cancelDrafts(arttId);
    },
    //跳转到医生认证
    toDoctorCertify() {
      this.$router.push("/doctorCertify");
    },
	async getPublishList(){
		const res = await this.$api.reqPublishList(this.$cookies.get('userId'));
		if(res.code===200){
			for(let i=0; i<res.rows.length; i++){
				res.rows[i].publishTime=this.timeFommater(res.rows[i].publishTime);
			}
			this.articleList=res.rows;
		}
	},
	timeFommater(value) {
		var dateee = new Date(value).toJSON();
		var date = new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '');
		return date;
	}
  }
}
</script>

<style lang="scss" scoped>
.breadcrumb_wrap {
  width: 100%;
  height: 40px;
  background-color: #fff;
  display: flex;
  align-items: center;
  padding-left: 10px;
  box-sizing: border-box;
  .current {
    font-size: 14px;
  }
}
.page_card{
  background-color: #fff;
  margin-top: 20px;
  padding: 20px;
}
</style>
